<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@include file="/include/common/formbackhead.jsp"%>
<%!
private class PageAction extends BaseAction{
	private String param1 = "";
	private String param2 = "";
	
	//准备action的环境变量 每次请次都会执行此方法 可在此方法中初如化一些变量
	protected void prepareActionEnv() throws Exception{
		param1 = utils.getHrNum();
		param2 = utils.getChName();
	}
	
	//加載頁面默認數據
	protected boolean onLoadDefault() throws Exception{
		//form.SetParamValue("test","測試");
		//String args[] = {"002639","005053","008690"};
		//form.SetParamValue("combox_hrnum",args);
		return true ;
	}
	
	//处理储存驗證
	protected void onSaveValidate() throws Exception{
		
	}
	
	//執行儲存
	protected void doSave() throws Exception{
		//ret.setOkInfo("儲存OK!");
		ret.Register("org","tee");
	}
	
	//处理刪除驗證
	protected void onDeleteValidate() throws Exception{
		
	}
	
	//執行刪除
	protected void doDelete() throws Exception{
		
	}
	
	//处理自定義操作
	protected boolean onCustomAction(String action) throws Exception{
		if(StringHelper.Compare("ajax_hrnum",action,true) == 0){
			onAjaxHrnum();
		}
		return super.onCustomAction(action);
	}
	
	protected void onAjaxHrnum() throws Exception{
		//首行要定义一个pageResult
		PageResult pageResult = ret.getCallResult();
		//取到UI页传递过来的参数
		String hrnum = form.gpsv("hrnum");
		
		//执行逻辑处理
		if(StringHelper.IsNullOrEmpty(hrnum)){
			//设置返回结果
			pageResult.setRetCode(Errors.NOK);
		}else{
			ResultSet rs = utils.executeQuery("info3", StringHelper.Format("select chname from hr..HR005 where HRNum='%1$s'",hrnum));
			if(rs.next()) {
				//设置返回数据
				pageResult.getData().FromResultSet(rs,true);
			}
		}
		
		//输出结果{"code":"","info":"","errors":[],"data":{"chname":"顏杰"},"bcode":"","ret":1,"okinfo":""}
		this.getPage().Output(pageResult.ToJSONString());
	}
}
%>
<%@include file="/include/common/formbackend.jsp"%>
